package com.cw.dubbo.consumer;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

import java.util.Objects;

@Configuration
public class NacosConfig implements EnvironmentAware {

    @Value("${spring.application.name}")
    public String applicationName;

    public String KEY_PROJECT_NAME = "project.name";

    @Override
    public void setEnvironment(Environment environment) {
        String projectName = System.getProperty(KEY_PROJECT_NAME);
        if (Objects.isNull(projectName)) {
            System.setProperty(KEY_PROJECT_NAME, applicationName);
        }
    }

}
